import type { PageResult, ResponseBody } from "@/api/typing";
import { request } from "@/utils/request";
import type {
  ApiParams,
  DeleteParams,
  QueryParams,
  QueryResult,
} from "./typing";

/**新增API */
export const add = (params: ApiParams) => {
  return request.post<ApiParams, ResponseBody>("/api/add", params);
};

/**修改API */
export const update = (params: ApiParams) => {
  return request.put<ApiParams, ResponseBody>("/api/update", params);
};

/**分页查询API */
export const queryByPage = (params: QueryParams) => {
  return request.get<QueryParams, ResponseBody<PageResult<QueryResult>>>(
    "/api/page",
    { params }
  );
};

/**删除API */
export const del = (params: DeleteParams) => {
  return request.delete<DeleteParams, ResponseBody>("/api/delete", { params });
};

/**根据接口IDS查询接口 */
export const queryByIds = (apiIds: string) => {
  return request.get<string, ResponseBody<QueryResult[]>>("/api/ids", {
    params: { apiIds },
  });
};
